<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>按钮</button>
  <script>
    const btn = document.querySelector('button');

    //赋值点击事件
    btn.onclick = () => {
      alert('点击了按钮111')
    }

    btn.onclick = () => {
      alert('点击了按钮333')
    }

    //追加点击事件
    btn.addEventListener('click', () => {
      alert('点击了按钮222')
    })

    // btn.addEventListener('click', () => {
    //   alert('点击了按钮444')
    // })

    btn.addEventListener('click', function() {
      // function 函数：通过 this 获取当前绑定事件的元素
      console.log('点击了按钮444',this)
    })

    btn.addEventListener('click', (e) =>{
       // 箭头函数：通过 e.currentTarget 获取当前绑定事件的元素
      console.log('点击了按钮555',e.currentTarget)
    })
  </script>

</body>

</html>